//
//  ViewController.m
//  两种Cell间的切换
//
//  Created by 小果 on 16/7/13.
//  Copyright © 2016年 小果. All rights reserved.
//

#import "ViewController.h"
#import "XGTableView.h"
#import "XGCollectionView.h"

@interface ViewController ()

@property (nonatomic, strong) XGCollectionView *collView;
@property (nonatomic, strong) XGTableView *tabView;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
    [btn addTarget:self action:@selector(changeWithContentView) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    XGTableView *tableView = [[XGTableView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.tabView = tableView;
    [self.view addSubview:tableView];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake(100, 120);
    layout.minimumInteritemSpacing = 10;
    layout.minimumLineSpacing = 20;
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    XGCollectionView *collectionView = [[XGCollectionView alloc] initWithFrame:CGRectMake(0, 64, ScreenW, ScreenH) collectionViewLayout:layout];
    self.collView = collectionView;

    
   
}
#pragma mark - 两种Cell之间的切换
-(void)changeWithContentView{
    
    if (self.view.subviews.lastObject == self.tabView){
        [self.tabView removeFromSuperview];
        [self.view addSubview:self.collView];
    }else{
        [self.collView removeFromSuperview];
        [self.view addSubview:self.tabView];
    }
}


@end
